package com.qf.service.impl;

import com.qf.dao.TypeRespository;
import com.qf.pojo.Type;
import com.qf.service.TypeService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class TypeServiceImpl implements TypeService {
    @Autowired(required = false)
    TypeRespository typeRespository;

    @Override
    public List<Type> findAll() {
        return typeRespository.findAll();
    }

    @Override
    public Type findById(Integer id) {
        return typeRespository.findById(id).get();
    }

    @Override
    public List<Type> findByLanguage(String language) {
        return typeRespository.findByLanguage(language);
    }

    @Override
    public List<Type> findByStyle(String style) {
        return typeRespository.findByStyle(style);
    }

    @Override
    public List<Type> findByChangJing(String changjing) {
        return typeRespository.findByChangJing(changjing);
    }

    @Override
    public List<Type> findByQingGan(String qinggan) {
        return typeRespository.findByQingGan(qinggan);
    }

    @Override
    public List<Type> findByZhuTi(String zhuti) {
        return typeRespository.findByZhuTi(zhuti);
    }

    @Override
    public Type addAndUpdate(Type type) {
        return typeRespository.saveAndFlush(type);
    }

    @Override
    public void delete(Integer id) {
        typeRespository.deleteById(id);
    }
}
